package pl.edu.agh.nn.functions;

public class SigmoidFunction implements IActivationFunction {

	private static final SigmoidFunction instance = new SigmoidFunction();
	private double threshold;

	public static SigmoidFunction getInstance() {
		return instance;
	}

	private SigmoidFunction() {

	}

	@Override
	public double compute(double x) {
		return 1.0 / (1.0 + Math.exp(-x + threshold));
	}

	@Override
	public double deriveComputation(double x) {
		return x * (1 - x);
	}

	public double getThreshold() {
		return threshold;
	}

	public void setThreshold(double threshold) {
		this.threshold = threshold;
	}

}
